/**
 * 
 */
package org.ssh2Maven.dao.systemDao.impl;

import java.util.List;

import javax.annotation.Resource;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.ssh2Maven.dao.systemDao.UserDao;
import org.ssh2Maven.model.systemModel.SystemUser;

/**
 * @author guangz
 * 
 */
public class UserDaoImpl implements UserDao
{
	private SessionFactory sessionFactory;

	public SessionFactory getSessionFactory()
	{
		return sessionFactory;
	}

	@Resource
	public void setSessionFactory(SessionFactory sessionFactory)
	{
		this.sessionFactory = sessionFactory;
	}

	@Override
	public SystemUser getUser(String loginId, String password)
	{

		Session session = sessionFactory.getCurrentSession();
		String queryString = "from SystemUser user where user.loginId=? and user.password=?";
		Query query = session.createQuery(queryString);
		query.setString(0, loginId);
		query.setString(1, password);

		Object user = query.uniqueResult();

		return user != null ? (SystemUser) user : null;
	}

	@Override
	public void updateUser(SystemUser user)
	{

	}

	@Override
	public void deleteUser(int userId)
	{

	}

	@Override
	public void getUser(int userId)
	{

	}

	@Override
	public List<SystemUser> findUser()
	{
		return null;
	}
}
